<template>
  <el-form
    ref="form"
    label-width="160px"
    :model="form"
    :rules="rules"
  >
    <el-row>
      <el-col :span="12">
        <el-form-item label="授权书有效开始时间" prop="effectiveStartDate">
          <el-date-picker
            v-model="form.effectiveStartDate"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
            format="yyyy-MM-dd"
            style="width: 100%"
            placeholder="请选择授权书有效开始时间"
            :disabled="disabled">
          </el-date-picker>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="授权书有效结束时间" prop="effectiveEndDate">
          <el-date-picker
            v-model="form.effectiveEndDate"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
            format="yyyy-MM-dd"
            style="width: 100%"
            placeholder="请选择授权书有效结束时间"
            :disabled="disabled"
          >
          <!-- :picker-options="endTimeOptions" -->
          </el-date-picker>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="授权书" prop="fileInfoRequestList">
          <MyDtFileUpload
            v-model="form.fileInfoRequestList"
            :fileType="[]"
            :fileLimit="3"
            :fileSize="50"
            :disabled="disabled"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
import { handleFile } from '../../utils'
import MyDtFileUpload from '../dt-fileUpload'

export default {
  components: { MyDtFileUpload },
  props: {
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {
        effectiveStartDate: '',
        effectiveEndDate: '',
        fileInfoRequestList: []
      },
      rules: {
        // effectiveStartDate: [{ required: true, trigger: 'change', message: '请选择授权书有效开始时间' }],
        // effectiveEndDate: [{ required: true, trigger: 'change', message: '请选择授权书有效结束时间' }],
        // fileInfoRequestList: [{ required: true, trigger: 'change', message: '请上传授权书' }]
      },
      fileType: []
    }
  },
  methods: {
    echoData(data) {
      this.form = data
      this.form.fileInfoRequestList = this.form.fileInfoList.map((file) => {
        return handleFile(file)
      })
    },
    init() {
      this.form = {}
      this.$refs.form.resetFields()
    },
    submit() {
      return this.form
    },
    validate() {
      let resultSts
      this.$refs.form.validate((result) => {
        resultSts = result
      })
      return resultSts
    }
  }
}
</script>

<style lang="scss" scoped>
.img-wrap {
  text-align: center;
}
.img-box {
  display: inline-block;
  width: 240px;
}
::v-deep .el-upload__tip {
  line-height: 16px;
}
</style>
